package com.eight.cloud.payment.common.enums;

import com.eight.cloud.core.global.exception.ParameterException;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

/**
 * 交易类型
 *
 * @EnumName: TradeType
 * @Author: TXC
 * @Date: 2025-11-27 17:40
 **/
@Getter
@AllArgsConstructor
@NoArgsConstructor
public enum TradeTypeEnum {
    APP("app", "APP支付"),
    JSAPI("jsapi", "公众号/小程序支付"),
    NATIVE("native", "扫码支付"),
    H5("h5", "H5支付"),
    CODEPAY("codepay", "付款码支付");

    private String code;
    private String name;

    public static TradeTypeEnum getByCode(String code) {
        for (TradeTypeEnum item : TradeTypeEnum.values()) {
            if (item.getCode().equals(code)) {
                return item;
            }
        }
        throw new ParameterException("交易类型不存在");
    }
}
